#include "common.h"

string countAndSay(int n)
{
	if (n == 1) return "1";
	else
	{
		string str = countAndSay(n - 1);
		char c = str[0];
		int num = 1;
		string ret;
		for (int i = 1; i < str.size(); i++)
		{
			if (c != str[i])
			{
				ret += (to_string(num));
				ret.push_back(c);
				c = str[i];
				num = 1;
			}
			else num++;
		}
		ret += (to_string(num));
		ret.push_back(c);
		return ret;
	}
}